#!/usr/bin/python
# Counts kmers with no mismatch.
# imports
import sys

# parameters.
in_file = sys.argv[1]
k = 17

# read file.
fin = open(in_file,"rb")
lines = fin.readlines()
fin.close()

# process file.
db = {}
first = True
cnt = 0
tot_seq = 0
for line in lines:
	# check if we start new entry.
	if line[0] == "@":
		# build kmer 1 mismatch.
		if first != True:
			# debug.
			cnt += 1
			if cnt == 100000: break
			
			# cut into kmers
			for i in range(len(seq)-k+1):
				# get kmer.
				key = seq[i:i+k]
				
				# check dicitonary.
				if key in db:
					db[key] += 1
				else:
					db[key] = 1
				
		else:
			first = False
			
		# clear.
		skip = False
		seq = ""
		continue
	
	elif line[0] == "+":
		skip = True
	
	# get seq
	if skip == False:
		seq += line.strip()

# sort by most frequent.
for key, value in sorted(db.iteritems(), key=lambda (k,v): (v,k)):
	print "%s: %s" % (key, value)
